﻿using IdentityService.Domain.Services;
using MediatR;

namespace IdentityService.Application.Commands
{
    public record ChangePermitsCommand(long Id, List<long> PermitIds) : IRequest<ChangePermitsResult>;

    public class ChangePermitsCommandHandler : IRequestHandler<ChangePermitsCommand, ChangePermitsResult>
    {
        private readonly IRoleService _roleService;
        public ChangePermitsCommandHandler(IRoleService roleService)
            => _roleService = roleService;

        public async Task<ChangePermitsResult> Handle(ChangePermitsCommand request, CancellationToken cancellationToken)
        {
            return await _roleService.ChangePermitsAsync(request.Id, request.PermitIds);
        }
    }
}
